package io.mft.datasource.mq.container.impl;

import io.mft.commons.config.mq.MqConsumer;
import io.mft.commons.function.ExecuteReturn;
import io.mft.commons.function.FunctionActionRequest;
import io.mft.commons.function.RequestValue;
import io.mft.commons.function.response.FunctionResponse;
import io.mft.commons.function.response.kv.KVMap;
import io.mft.datasource.mq.container.MessageProcessor;
import io.mft.dev.base.ApiInvoker;

public class MessageFuncNoProcessor implements MessageProcessor {

	@Override
	public ExecuteReturn process(MqConsumer consumer,KVMap message) {
        RequestValue requestValue=new RequestValue();
        requestValue.putAll(message);
        FunctionActionRequest request=new FunctionActionRequest(requestValue);
        FunctionResponse response=ApiInvoker.instance().invoke(consumer.getHandler(), request);
        ExecuteReturn executeReturn=ExecuteReturn.builder().code(response.getErrorNo()).message(response.getErrorInfo()).build();
		return executeReturn;
	}

}
